package com.zmn.plat.dubbo.impl.plat.contractmodel;

import javax.annotation.Resource;

import org.apache.dubbo.config.annotation.Service;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
import com.zmn.plat.business.interfaces.plat.contract.model.PlatContractModelBService;
import com.zmn.plat.common.exception.PlatException;
import com.zmn.plat.dubbo.interfaces.plat.contractmodel.PlatContractModelListRemoteService;
import com.zmn.plat.dubbo.utils.DubboConsts;

import lombok.extern.slf4j.Slf4j;

/**
 * 描述：平台服务合同模式dubbo接口实现类
 * 
 * @author linfeng
 * @version v1.0
 * @since 2020/09/07
 */
@Slf4j
@Service(version = DubboConsts.INTERFACE_VERSION, validation = "true")
public class PlatContractModelListRemoteServiceImpl implements PlatContractModelListRemoteService {

    @Resource
    PlatContractModelBService platContractModelBService;

    @Override
    @ReadOnlyConnection
    public ResponseDTO<Integer> getPlatContractModel(Integer plat) {
        log.error("getPlatContractModel 参数为plat={}", plat);
        try {
            Integer contractModel = platContractModelBService.getPlatContractModel(plat);
            return ResponseDTO.success(contractModel);
        } catch (PlatException e) {
            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
        } catch (Exception e) {
            log.error("getPlatContractModel error.plat={}", plat);
            return ResponseDTO.fail("内部错误");
        }
    }
}
